/*
Joseph Ratway
Garrett Brown
Bret Parker
*/

//imports
import java.util.*;
import java.io.*;
import java.net.*;

public class Main
{
	public static void main(String[] args) throws Exception
	{        
		ServerSocket listener = new ServerSocket(0);
        System.out.println("Reversi Server is running on Socket:" + listener.getLocalPort());
		System.out.println("Use telnet to connect to the Server.");
		Socket socket = listener.accept();
		
		ReversiGame playing = new ReversiGame(socket);
		playing.out = new PrintWriter(socket.getOutputStream(), true);
		
		playing.out.println("Welcome");
		
		//playing.printBoardToClient(socket);
		//System.out.println("Reversi Server is Running on Socket:");
		try
		{
			while(true)
			{
				playing.setupStreams(socket);
				playing.startGame(socket);
			}
		}
		finally
		{
				socket.close();
				listener.close();
		}
	}
}